import { reqGetSearchInfo } from "@/api";
//search 模型的小仓库
const state = {
    searchList:[],
};

const mutations = {
    GETSEARCHLIST(state,searchList){
        state.searchList=searchList;
    },
};

const actions = {
    async getSearchList({ commit }, params = {}) {
        let result = await reqGetSearchInfo(params);
        if(result.code==200){
            commit("GETSEARCHLIST",result.data);
        }
    }
};

// 计算属性：项目当中getters主要的作用是：简化仓库中的数据
// getters可以把我们将来在组件当中需要用的数据简化一下
const getters = {
    goodsList(state){
        return state.searchList.goodsList ||[]
    },
    trademarkList(state){
        return state.searchList.trademarkList
    },
    attrsList(state){
        return state.searchList.attrsList
    }
};

export default {
    state,
    mutations,
    actions,
    getters
}